
/**
 房间运营状态
 *
*/
import { StationNetwork } from "GameLoop/Path/StationNetwork";
import { TeamUpgrader } from "GameLoop/WorldState/EntityManager/Entitys/team/upgrader/TeamUpgrader";
import { approach } from "GameLoop/WorldState/mount/move/action.virtual";
import { State } from "framework/FSM/AState";
/**
 * 运输网络决策.
 * 通过计算外矿到房间中心的距离。计算需要多少个carry。然后发布任务并且限制被共享的次数。
 * 没有任务的运输爬自己领取最近的任务。去资源点等待资源.
 */

export class TeamUpgradeState<T extends IStateArg<TeamUpgrader >> extends State<T>
{
    public getActions(arg:T):Action[]
    {
        const room = Game.rooms[arg.entity.region];
        const task = room.findTaskById<ITask<ITeamTaskData<"upgrade">>>(arg.entity.getNodeMemory().bindTask);
        if(!task)
        {
            arg.entity.log(`warn`,'找不到绑定任务');
            room.removeEntityByID(arg.entity.GUID());
            return []
        }
        const workroom = Game.rooms[task.data.room];
       
        const creeps = arg.entity.creeps;
        creeps.forEach(e=>
            {
                approach(e,arg.entity.Controller.pos,3)
            })
        arg.entity.dowork(workroom,creeps.filter(e=>e.isSpawned()));
      
        arg.entity.visual();
       // controller.UpgraderComponent.dowork(arg.entity.creeps);

        return [];
    }
    
}
